<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Gym Rat | Exercise Info: ${exercise.name }</title>
</head>
<body>
<jsp:include page="/includes/nav.jsp" />
<h1>${exercise.name }</h1>
<c:choose>
	<c:when test="${user.admin || exercise.custom}">
		<p>You may edit this exercise</p>
	</c:when>
	<c:otherwise>
		<p>You do not have permission to edit this exercise</p>
	</c:otherwise>
</c:choose>
<form action="update" method="post"><c:if
	test="${user.admin || exercise.custom}">
		New Name:
			<input type="text" name="newName" value="${exercise.name }">
	<br>

</c:if> Muscle Group: <c:choose>
	<c:when test="${user.admin || exercise.custom}">
		<select name="newMuscleGroup">
			<c:forEach var="mg" items="${allMuscleGroups}">
				<option value=${mg.key }
					<c:if test="${exercise.muscleGroupId == mg.key }">
						selected="selected"
						</c:if>>${mg.value
				}</option>

			</c:forEach>
		</select> (currently: ${exercise.muscleGroup })
			</c:when>
	<c:otherwise>
				${exercise.muscleGroup }
			</c:otherwise>
</c:choose> <br>
<div class="tableSubHeader">Variations: <c:if
	test="${user.admin || exercise.custom}">
	<a class="headerLink"
		href="<c:url value='/variation/list?redir=/exercise/info?id=${exercise.id }' />">Add
	a New Variation</a>
</c:if></div>
<br>
<c:choose>
	<c:when test="${!user.admin && !exercise.custom}">
		<c:forEach var="variation" items="${exercise.variations }">
			<div class="checkBoxOption">${variation.name}</div>
		</c:forEach>
	</c:when>
	<c:otherwise>
		<c:forEach var="var" items="${allVariations}">

			<c:set var="contains" value="false" />
			<c:forEach var="item" items="${exercise.variations}">
				<c:if test="${item.id eq var.id}">
					<c:set var="contains" value="true" />
				</c:if>
			</c:forEach>
			<div class="checkBoxOption"><input type="checkbox"
				name="variation" id="variation_${var.id }" value="${var.id }"
				<c:if test="${contains == true}">
				checked=" yes"
				</c:if> />
			<label for="variation_${var.id }">${var.name }</label></div>
		</c:forEach>

	</c:otherwise>
</c:choose>
<div class="tableSubHeader">Equipment: <c:if
	test="${user.admin || exercise.custom}">
	<a class="headerLink"
		href="<c:url value='/equipment/list?redir=/exercise/info?id=${exercise.id }' />">Add
	New Equipment</a>
</c:if></div>
<c:choose>
	<c:when test="${!user.admin && !exercise.custom}">
		<c:forEach var="equipment" items="${exercise.equipment }">
			<div class="checkBoxOption">${equipment.name}</div>
		</c:forEach>
	</c:when>
	<c:otherwise>
		<c:forEach var="equip" items="${allEquipment}">

			<c:set var="contains" value="false" />
			<c:forEach var="item" items="${exercise.equipment}">
				<c:if test="${item.id eq equip.id}">
					<c:set var="contains" value="true" />
				</c:if>
			</c:forEach>
			<div class="checkBoxOption"><input type="checkbox"
				name="equipment" value="${equip.id }" id="equip_${equip.id}"
				<c:if test="${contains == true}">
				checked=" yes"
				</c:if> />
			<label for="equip_${equip.id}">${equip.name }</label></div>
		</c:forEach>

	</c:otherwise>

</c:choose>
<p style="clear: both"></p>
<input type="hidden" name="id" value="${exercise.id }"> <c:if
	test="${user.admin || exercise.custom}">
	<br>
	<input class="clear" type="button" onClick="submit()" value="Update">
</c:if></form>
<hr />
Lots of further information about exercise goes here.
<br>

</body>
</html>